/*
 * @lc app=leetcode.cn id=452 lang=swift
 *
 * [452] 用最少数量的箭引爆气球
 */

// @lc code=start
class Solution {
    func findMinArrowShots(_ points: [[Int]]) -> Int {
        let newPoints = points.sorted(by: { $0[1] < $1[1] })
        var num = 1, endP = newPoints[0][1]

        for i in 1..<newPoints.count {
            if endP >= newPoints[i][0] {
                continue;
            } else {
                num += 1
                endP = newPoints[i][1]
            }
        }
        return num
    }
}
// @lc code=end

